# Maintainer: Forza <forza@tnonline.net>
pkgname=scsi-tgt
pkgver=1.0.93
pkgrel=0
pkgdesc="user-space iSCSI target daemon"
url="https://github.com/fujita/tgt"
arch="all"
license="GPL-2.0-only"
makedepends="
	docbook-xsl
	libxslt
	linux-headers
	"
subpackages="$pkgname-openrc $pkgname-doc $pkgname-scripts::noarch"
source="$pkgname-$pkgver.tar.gz::https://github.com/fujita/tgt/archive/refs/tags/v$pkgver.tar.gz
	ldflags.patch
	reg.patch
	tgt-admin.confd
	tgt-admin.initd
	tgtd.confd
	tgtd.initd
	"
builddir="$srcdir/tgt-$pkgver"
options="!check" # no test suite present

build() {
	make LDFLAGS="$LDFLAGS"
}

package() {
	make DESTDIR="$pkgdir" install

	install -Dm755 "$srcdir"/tgtd.initd \
		"$pkgdir"/etc/init.d/tgtd
	install -Dm644 "$srcdir"/tgtd.confd \
		"$pkgdir"/etc/conf.d/tgtd
	install -Dm755 "$srcdir"/tgt-admin.initd \
		"$pkgdir"/etc/init.d/tgt-admin
	install -Dm644 "$srcdir"/tgt-admin.confd \
		"$pkgdir"/etc/conf.d/tgt-admin
}

doc() {
	default_doc
	amove etc/tgt/examples
}

scripts() {
	pkgdesc="$pkgdesc (perl/bash scripts)"
	depends="$pkgname=$pkgver-r$pkgrel bash perl perl-config-general"

	amove \
		usr/sbin/tgt-admin \
		usr/sbin/tgt-setup-lun
}

sha512sums="
7962fe62d26d30cb63e695181136c8451b4bb9747c5f78098a8820a4a3da7fa344317529b5e1244fb52eabde6415a805705a4f5b2f2313963a1fe93432e76d66  scsi-tgt-1.0.93.tar.gz
84a3ae20cff6e265dfbb7ca47390303ac6caed38f1112ed0227fb9742903395725e269bcc4b6ebd08db710301bc49236e95d5d242abb2a5f9ba94335aae6b7d6  ldflags.patch
361233a15475988dd65eae7d7eaf53b94c05630f2c5ad80923e57063a8ef92c4c7630f4aef6bdadbd2ab0a7c779a3e196a400c7ec397a54c61bc19963dfda422  reg.patch
1eac80c05c462a325582aa610f5f37f427eb70695bd95b66fe368fbbee24455b7cb80162a2925919544253703a83fd6a96f1d1a383ddf3889b44d82904fcae50  tgt-admin.confd
d866aac5bbe2eea0c55ac10852ceecfa0ab2edc2b437505cb6caf116b8fd1668e3ac3ecfba96de06748632464ee1fcd8e3d338f304aa3451480b4394059ed744  tgt-admin.initd
01d89be24c126beb9765be5fbd840aaf9883fd22af2f9f02af8c42e318cf651ec07072e5a1d16b63c66d109591cb754da61ffab01de96668663ada0aa87ccf0c  tgtd.confd
e1aecf420e0656b1984043b10480af50b9cba73b91e691ae08229184edec799d7008d0fd4fe093f5b455a6c771b40c6007462eeb487ccf25014e96bacf13061b  tgtd.initd
"
